Skip to content

[AQUA] CLI to verify policies to perform operations related to AQUA. #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 10, 2025

Conversation

amitkrprajapati
Copy link
Member

@amitkrprajapati amitkrprajapati commented Jun 30, 2025

This utility is designed to help users verify whether they have the necessary permissions to perform common AQUA workflows, such as model registration, deployment, evaluation, and fine-tuning.

Common Methods:
ads aqua verify_policies common_policies
ads aqua verify_policies model_register
ads aqua verify_policies model_deployment
ads aqua verify_policies evaluation
ads aqua verify_policies finetune

Help:
ads aqua verify_policies -- --help

Usage: 'ads aqua' verify_policies <command|value>
available commands: common_policies | evaluation | finetune |
model_deployment | model_register
available values: model_id

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 30, 2025
Copy link

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

📌 Cov diff with main:

Coverage-31%

📌 Overall coverage:

Coverage-58.02%

@mrDzurb mrDzurb changed the title CLI to verify policies to perform operations related to AQUA. [AQUA] CLI to verify policies to perform operations related to AQUA. Jun 30, 2025
@mrDzurb
Copy link
Member

mrDzurb commented Jul 3, 2025

Could you add description to this PR?

Copy link

github-actions bot commented Jul 3, 2025

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

github-actions bot commented Jul 3, 2025

📌 Cov diff with main:

Coverage-93%

📌 Overall coverage:

Coverage-58.44%

Copy link

github-actions bot commented Jul 4, 2025

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

github-actions bot commented Jul 4, 2025

📌 Cov diff with main:

Coverage-94%

📌 Overall coverage:

Coverage-58.44%

Copy link

github-actions bot commented Jul 8, 2025

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

UNVERIFIED = "UNVERIFIED"


@dataclass(repr=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: We are trying to move everything to pydantic classes instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These classes are inheriting from DataClassSerializable. Do we have something similar with Pydantic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap we do have

https://github.com/oracle/accelerated-data-science/blob/main/ads/aqua/config/utils/serializer.py

utils.list_compartments.__name__: {
"name": "List Compartments",
"error": "Unable to retrieve the list of compartments. Please verify that you have the required permissions to list compartments in your tenancy. ",
"policy_hint": "Allow dynamic-group aqua-dynamic-group to inspect compartments in tenancy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed during the syncup, let's also try to add a link to the GH docs, where the policies can be setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a log: logger.info(f"Refer to: {POLICY_HELP_LINK}")

This log will be printed everytime when a operation fails.
POLICY_HELP_LINK: https://github.com/oracle-samples/oci-data-science-ai-samples/blob/main/ai-quick-actions/policies/README.md

subnet_id = kwargs.pop("subnet_id", None)
job_infrastructure_type = "STANDALONE" if subnet_id is not None else "ME_STANDALONE"

response = self.aqua_model.ds_client.create_job(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current implementation, I am creating Job with shell environment and running a simple "echo" command. I am directly uploading the artifact data without saving the file locally.
In job run: I am waiting for run to complete, by constantly monitoring lifecycle state.

I found ads.job little untidy to achieve the same.

@mrDzurb
Copy link
Member

mrDzurb commented Jul 8, 2025

Will the ads aqua verify_policies --help show the guidance, how the verifier can be used, if not, then we should add this.
@amitkrprajapati

Copy link

github-actions bot commented Jul 8, 2025

📌 Cov diff with main:

Coverage-94%

📌 Overall coverage:

Coverage-58.45%

Copy link
Member

@VipulMascarenhas VipulMascarenhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some minor comments

using Oracle Accelerated Data Science (ADS) SDK.
"""
def __init__(self):
self.aqua_model = AquaModelApp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to keep it better readable/maintainable, might be good to load most the below clients directly from AquaApp class, and use aqua_model for testing individual functions. ideally, clients should have been reused in the child classes in aqua, but we've done it on few instances and not all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the list operations use limit=3, so they fetch data directly from the OCI client. If I change the implementation to ads specific, it tries to list all resources even if it has multiple pages. For policy verification, a list operation with a limit is enough.

model_id = self.aqua_model.ds_client.create_model(create_model_details=create_model_details).data.id
self.aqua_model.ds_client.create_model_artifact(
model_id=model_id,
model_artifact=b"7IV6cktUGcHIhur4bXTv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use a constant for this, also add comment on what this string means.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to CONSTANT variable. This is dummy model_artifact bytes.

self.job_id = None
self.limit = 3

def list_compartments(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstrings for all functions.

log.txt Outdated
@@ -0,0 +1,24 @@
👋 Waiting, Amit!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this file need to be included?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link

github-actions bot commented Jul 9, 2025

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

github-actions bot commented Jul 9, 2025

📌 Cov diff with main:

Coverage-92%

📌 Overall coverage:

Coverage-58.48%

Copy link

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

📌 Cov diff with main:

Coverage-92%

📌 Overall coverage:

Coverage-58.48%

Copy link

⚠️ This PR changed pyproject.toml file. ⚠️

  • PR Creator must update 📃 THIRD_PARTY_LICENSES.txt, if any 📚 library added/removed in pyproject.toml.
  • PR Approver must confirm 📃 THIRD_PARTY_LICENSES.txt updated, if any 📚 library added/removed in pyproject.toml.

Copy link

📌 Cov diff with main:

Coverage-92%

📌 Overall coverage:

Coverage-58.48%

Copy link
Member

@VipulMascarenhas VipulMascarenhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@mrDzurb mrDzurb merged commit 343f7e1 into main Jul 10, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants